﻿package server_common;

class ExtendedManager<T: php.db.Object> extends php.db.Manager<T> {

	public function new(classval : Class<php.db.Object>) {
		super(classval);
	}
	
	public function buildInList<T>(field: String, values: Iterable<T>): String {
		var filtered = Lambda.filter(values, function (v) { return null != v; } );
		if (filtered.isEmpty()) {
			return "false";
		}
		
		var buf = new StringBuf();
		buf.add(quoteField(field));
		buf.add(" in (");
		var first = true;
		for (val in filtered) {
			if (first) {
				first = false;
			} else {
				buf.add(",");
			}
			
			addQuote(buf, val);
		}
		
		buf.add(")");
		
		return buf.toString();
	}
}